#include "widget.h"
#include "ui_widget.h"
#include <QResizeEvent>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //先让QLabel设置和窗口一样大
    QRect rect = geometry();
    ui->label->setGeometry(0, 0, rect.width(), rect.height());

    QPixmap pixmap("c:/windowPicture/th.jpg");
    ui->label->setPixmap(pixmap);

    ui->label->setScaledContents(1);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::resizeEvent(QResizeEvent* event)
{
    qDebug()<<event->size();
    ui->label->setGeometry(0, 0, event->size().width(), event->size().height());
}

